/*
 * 本文件定义用户身份类型
 * 以供外部使用，如注册页面
 *
 **/

import { defineStore } from 'pinia';

export interface Role {
  value: string;
  label: string;
  disabled: boolean;
}

export const useRoleStore = defineStore('role', {
  state: () => ({

    roles: [

      { value: 'USER', label: '用户', disabled: false },
      { value: 'MANAGER', label: '管理员', disabled: true },

    ] as Role[],
  }),

  getters: {

    getRoleName: (state) => (role: string) => {
      const roleObj = state.roles.find((r) => r.value === role);
      return roleObj ? roleObj.label : role;
    },
  },
});